#ifndef __ming_fyp_render_RenderedTextureImpl_h__
#define __ming_fyp_render_RenderedTextureImpl_h__

//------------------------------------------------------------------------------
// header includes
#include "fyp/render/RenderedTexture.h"

struct IDirect3DTexture9;
struct IDirect3DSurface9;

//------------------------------------------------------------------------------
namespace ming
{
namespace fyp
{
namespace render
{
	class TResourceFactory;

	//--------------------------------------------------------------------------
	class TRenderedTextureImpl : public IRenderedTexture
	{
	public:
		
		//------------------------------
		// #cstor & #dstor
		TRenderedTextureImpl(FORMAT format, size_t w, size_t h, bool hasDepth, TResourceFactory *resFactory);
		~TRenderedTextureImpl();
		
		//------------------------------
		// external operations
		virtual void* GetApiTexture();
		virtual void* GetApiRenderTarget();
		virtual void* GetApiDepthBuffer();

		virtual tuple<size_t, size_t> GetLogicalSize();
		virtual tuple<size_t, size_t> GetActualSize();

		virtual void SetAddressMode(TAddressMode u, TAddressMode v, TAddressMode w);
		virtual void SetFilterMode(TFilterMode minFilter, TFilterMode magFilter, TFilterMode mipFilter);
		
		virtual TAddressModeSettings GetAddressMode();
		virtual TFilterModeSettings GetFilterMode();

	private:
		//------------------------------
		// internal attributes
		TResourceFactory *mResFactory;

		tuple<size_t, size_t> mLogicalSize;

		TAddressModeSettings mAddressModes;
		TFilterModeSettings mFilterModes;
		IDirect3DTexture9* mTexture;
		IDirect3DSurface9* mRenderTarget;
		IDirect3DSurface9* mDepthBuf;
		
		//------------------------------
		// internal operations
		void FindMatchingPow2Size(size_t &w,size_t &h);
	};
	
	//--------------------------------------------------------------------------
}
}
}


#endif	//__ming_fyp_render_RenderedTextureImpl_h__